import tkinter as tk
import customtkinter as ctk
import cursor_switcher

class MainApplication:
    def __init__(self, root):
        self.root = root
        self.root.title("cursor switcher")
        self.root.geometry("300x180")
        ctk.set_appearance_mode("dark")
        ctk.set_default_color_theme("dark-blue")
        
        # 只保留一个按钮
        btn = ctk.CTkButton(
            self.root,
            text="一键重置机器码", 
            command=self.handle_quick_action,
            width=200,
            height=40
        )
        btn.pack(pady=(30, 10))
    
        # 增加一个标签用于显示提示信息
        self.result_label = ctk.CTkLabel(
            self.root,
            text="",
            font=("Arial", 12),
            text_color="#10b981"
        )
        self.result_label.pack(pady=(10, 0))
    
    def handle_quick_action(self):
        try:
            switcher = cursor_switcher.CursorAccountSwitcher()
            machine_code_reset = switcher.modify_machine_code()
            if machine_code_reset:
                msg = "机器码重置成功"
            else:
                msg = "机器码重置可能部分成功或失败"
            self.result_label.configure(text=msg, text_color="#10b981")
        except Exception as e:
            msg = f"重置机器码时出错: {e}"
            self.result_label.configure(text=msg, text_color="#ef4444")

if __name__ == "__main__":
    root = ctk.CTk()
    app = MainApplication(root)
    root.mainloop() 